package com.gibs.peixunapi.controller;

import com.gibs.peixunapi.enums.ResultEnum;
import com.gibs.peixunapi.model.ActionLog;
import com.gibs.peixunapi.result.Result;
import com.gibs.peixunapi.service.ActionLogService;
import com.gibs.peixunapi.utils.ResultUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.transaction.Transactional;
import javax.validation.Valid;
import java.util.ArrayList;

/**
 * 功能：【操作日志】的后台控制器
 * 项目：装配式培训平台 
 * 日期：2020-08-20
 * 作者：梁嘉伟
 */

@Slf4j
@RestController
@RequestMapping("/ActionLogs")
public class ActionLogs extends Application {

	@Autowired
	private ActionLogService ActionLogService;

	@Transactional
	@PostMapping("/create")
	public Result create(@Valid ActionLog object, BindingResult bindingResult) {
		Result errorList = getResult(bindingResult);
		if (errorList != null) {
			return errorList;
		}
		return ActionLogService.create( object);
	}

	@Transactional
	@PostMapping("/save")
	public Result save(@Valid ActionLog object, BindingResult bindingResult) {
		Result errorList = getResult(bindingResult);
		if (errorList != null) {
			return errorList;
		}
		return ActionLogService.save( object);
	}

	@PostMapping("/delete")
	public Result delete(Integer id) {
			 return ActionLogService.delete(id);
	}

	@GetMapping("/get")
	public Result get(Integer id) {
		 return ActionLogService.get(id);
	}

	@GetMapping("/getList")
	public Result getList(String key) {
		 return ActionLogService.getList(key);
	}

	@GetMapping("/getListPage")
	public Result getListPage(String key, Integer current, Integer limit) {
		return ActionLogService.getListPage(key, current, limit);
	}

	@GetMapping("/getOptions")
	public Result getOptions(String key) {
		return ActionLogService.getOptions(key);
	}



}

